//把配置项单独处理


let token = ' ';

function service(options = {}) {
	options.url = `${options.url}`;
	//配置请求头
	options.header = {
		'content-type': 'application/json',
		// 'accessToken': `${token}` //Bearer 
	};


	return new Promise((resolved, rejected) => {
		//成功
		options.success = (res) => {
			if (res.statusCode == '200') { //请求成功
				resolved(res.data);
			} else {
				uni.hideLoading();
				uni.showToast({
					icon: 'none',
					duration: 3000,
					title: `${res.data.error}`
				});
				rejected(res.data.error); //错误
			}

		}
		//错误
		options.fail = (err) => {
			rejected(err); //错误
		}
		uni.request(options);

	});
}
export default service;